package com.bishe.job;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bishe.entity.WzOut;
import com.bishe.service.WzOutService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;


@Component
public class WzJob {

    @Resource
    private WzOutService wzOutService;

    @Scheduled(cron = "*/1 * * * * ?")
    public void doJob() {
        Date now = DateUtil.parse(DateUtil.now(),"yyyy-MM-dd HH:mm:ss");
        List<WzOut> list = wzOutService.list(Wrappers.lambdaQuery(WzOut.class).eq(WzOut::getStatus, 2));
        list.forEach(s -> {
            if (s.getYjsj() != null && now.equals(s.getYjsj())) {
                System.out.println("执行签收: "+now);
                s.setStatus(3);
                wzOutService.updateById(s);
            }
        });
    }
}
